package com.baitiaojun.moments.factory;

import com.baitiaojun.api.domain.moments.UserDailyMoments;
import com.baitiaojun.api.domain.moments.UserMoments;
import com.baitiaojun.api.domain.moments.UserVideoMoments;
import com.baitiaojun.moments.service.DailyMomentsService;
import com.baitiaojun.moments.service.VideoMomentsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

/**
 * @类名 UserVideoMomentsFactoryImpl
 * @描述 TODO
 * @作者 白条君
 * @创建日期 2023/3/2 12:59
 * @版本 1.0
 */
@Component
public class UserMomentsFactory {

    @Lazy
    @Autowired
    private VideoMomentsService videoMomentsService;

    @Lazy
    @Autowired
    private DailyMomentsService dailyMomentsService;

    public UserMoments createMoments(String type, Long contentid, Long userId, UserMoments userMoments) throws Exception {
        if ("0".equals(type)) {
            UserVideoMoments userVideoMoments = videoMomentsService.getUserVideoMoments(contentid, userId);
            userVideoMoments.setCreatetime(userMoments.getCreatetime());
            return userVideoMoments;
        } else if ("1".equals(type)) {
            UserDailyMoments dailyMoments = dailyMomentsService.getDailyMoments(contentid, userId);
            dailyMoments.setCreatetime(userMoments.getCreatetime());
            return dailyMoments;
        } else if ("2".equals(type)) {
            return null;
        } else {
            return null;
        }
    }
}
